package com.fly.sms.util;


/**
 * 
 * 
 * Title:
 * 
 * Description:
 * 
 * Copyright: Copyright (c) 2008
 * 
 * @author haoxz11
 * @created Mar 7, 2008 1:46:45 PM
 * @version $Id: Pagination.java,v 1.1 2010/04/09 03:27:07 airsou Exp $
 */
public class Pagination {

	private int currentPage = 1;

	private int nextPage = -1;

	private int previousRage = -1;

	private int totalPage = 0;

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getNextPage() {
		return nextPage;
	}

	public void setNextPage(int nextPage) {
		this.nextPage = nextPage;
	}

	public int getPreviousRage() {
		return previousRage;
	}

	public void setPreviousRage(int previousRage) {
		this.previousRage = previousRage;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getTotalRow() {
		return totalRow;
	}

	public void setTotalRow(int totalRow) {
		this.totalRow = totalRow;
	}

	public int getpSize() {
		return pSize;
	}

	public void setpSize(int pSize) {
		this.pSize = pSize;
	}

	private int totalRow = 0;

	private int pSize = 1;

	/**
	 * Constructor for the Pager object
	 * 
	 * @param total_count
	 *            Description of the Parameter
	 * @param current_page
	 *            Description of the Parameter
	 * @param show_num
	 *            Description of the Parameter
	 */
	public Pagination(int totalRow, int currentPage, int pSize) {
		this.totalRow = totalRow;
		totalPage = (totalRow - 1) / pSize + 1;
		this.currentPage = currentPage;
		this.currentPage = (this.currentPage <= 0) ? 1 : this.currentPage;
		this.currentPage = (this.currentPage > totalPage) ? totalPage
				: this.currentPage;
		this.previousRage = this.currentPage - 1;
		this.nextPage = this.currentPage + 1;
	}
	
	public boolean hasNextPage(){
		return this.currentPage<this.totalPage;
	}
	
	public boolean hasPrePage(){
		return this.currentPage>1;
	}
}